import request from '@/utils/request.ts'
import type { ApiResult } from '@/api/api.ts'
import type { LeftMenuVo, Menu, MenuAddDTO, MenuModDTO } from './type.ts'

const BASE_URL = '/admin/api/v1/acl/menu'

const API = {
  BASE_URL,
  MENU_ME_URL: BASE_URL + '/me',
  MENU_TREE_URL: BASE_URL + '/tree',
  EXCLUDE_BUTTON_URL: BASE_URL + '/exclude/button',
}
//获取当前登录人菜单信息
export const loginMenu = () => {
  return request.get<any, ApiResult<LeftMenuVo[]>>(API.MENU_ME_URL)
}
export const menuTree = () => {
  return request.get<any, ApiResult<Menu[]>>(API.MENU_TREE_URL)
}
export const exclude = () => {
  return request.get<any, ApiResult<Menu[]>>(API.EXCLUDE_BUTTON_URL)
}

export const menuAdd = (data: MenuAddDTO) => {
  return request.post<any, ApiResult<unknown>>(API.BASE_URL, data)
}
//修改模块信息
export const menuMod = (data: MenuModDTO) => {
  return request.put<any, ApiResult<unknown>>(API.BASE_URL, data)
}
export const menuDel = (id: string) => {
  return request.delete<any, ApiResult<unknown>>(API.BASE_URL + `/${id}`)
}
